goog.provide('georeferencer.chart.Pie');



/**
 * @constructor
 */
georeferencer.chart.Pie = function() {
   this.sectors_ = [];
   this.sum_ = 0;
};



/**
 * @return {number} 
 */
georeferencer.chart.Pie.prototype.getNumberOfSectors = function() {
  console.log(this.sectors_.length);
  return this.sectors_.length;
};


/**
 */
georeferencer.chart.Pie.prototype.addSector = function(sector) {
  this.sectors_[this.getNumberOfSectors()]=sector;
  this.sum_+=sector.getCount();
};


/**
 
 */
georeferencer.chart.Pie.prototype.getSectorAt = function(index) {
  return this.sectors_[index];
};


georeferencer.chart.Pie.prototype.getSum = function() {
  return this.sum;
};


georeferencer.chart.Pie.prototype.attachPercentages = function() {
  var ratio = 100/this.sum_;
  for(var i = 0; i < this.getNumberOfSectors(); i++) {
    var sector = this.getSectorAt(i);
    var percentage = ratio*sector.getCount();
    var roundedPercentage = Math.round(percentage*10)/10;    
    sector.setPercentage(roundedPercentage);
  }  
}